/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tomasio.projects.lua.controllers;


import com.future.projects.imobiliaria.forms.PasswordForm;

import javax.validation.Valid;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.WebRequest;

/**
 *
 * @author dctp
 */
@Controller
@RequestMapping("/settings")
public class SettingsController {

   

    @RequestMapping({"/", "/index", ""})
    public String showIndex(Model model) {
        return "settings";
    }

    
    @RequestMapping("/edit_password")
    public String showEditPassword(Model model) {
        PasswordForm passwordForm = new PasswordForm();
        model.addAttribute(passwordForm);
        return "settings/form_password";
    }

    @RequestMapping("/save_password")
    public String savePassword(Model model, @Valid PasswordForm passwordForm, BindingResult bindingResult, WebRequest request) {

        if (bindingResult.hasErrors()) {
            return "settings/form_password";
        }

        

        return "settings";
    }
}
